package com.example.aqarapp.view.utils;

import java.text.NumberFormat;

public class MathUtils {

    public static int getPercentageFromString(String str){
        NumberFormat nf=NumberFormat.getPercentInstance();
        try {
            Number m = nf.parse(str);
            int i = m.intValue();
            return i;
        } catch (Exception e) {
            return -1;
        }
    }

    //灯泡色温 0-100 映射到175到370
    public static  int transformColor(int colorTemperature){
        return (((370-175)/100)*colorTemperature)+175;
    }
}
